package cas.server;

import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;

public class SecurityKey {
    private static KeyPair keyPair = null;

    private SecurityKey() {}

    public static KeyPair getKeyPair() {
        return keyPair;
    }

    public static void init() {
        initKeyPair();
    }

    private static void initKeyPair() {
        try {
            KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA");
            keyPairGenerator.initialize(2048);
            keyPair = keyPairGenerator.generateKeyPair();
        } catch (NoSuchAlgorithmException e) {
            throw new RuntimeException(e);
        }
    }

}
